<%@ page language="java" contentType="text/html;charset=utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@page import="cn.jdy.framework.util.IpUtil"%>
<%
	String ip =IpUtil.getIp(request);// 访问者IP
	request.setAttribute("ipaddress", ip);
	%>
<!DOCTYPE html>

<html lang="en" class="no-js">

<head>
    <jsp:include page="../common/common.jsp"/>
</head>
<body class="page-header-fixed">
<jsp:include page="../common/header.jsp"/>
<div class="clearfix">
</div>
<div class="page-container">
    <div class="page-sidebar-wrapper"><jsp:include page="../common/menu.jsp"/></div>
    <div class="page-content-wrapper">
        <div class="page-content">
            <div class="row">
                <div class="col-md-12">
                    <form class="form-horizontal form-row-seperated" id="form" method="post" action="${path}/lhkworks/save">
                        <div class="portlet box purple">
                            <div class="portlet-title">
                                <div class="caption">
                                    <i class="fa fa-shopping-cart"></i>机具管理
                                </div>
                                <div class="actions btn-set">
                                    <input class="btn default" type="button" value="取消" onclick="javascript:history.go(-1);">
                              
                                 <%--  <c:choose>
									       <c:when test="${data.topTime=='0'||data.topTime==null}">
									              <button type="button" onclick="saveDz()" class="btn  btn-success"><i class="fa icon-flag"></i> 顶置 </button>
									       </c:when>
									       <c:otherwise>
									             <button type="button" onclick="saveRmdz()" class="btn btn-info"><i class="fa  icon-repeat"></i> 取消顶置 </button>
									       </c:otherwise>
									</c:choose> --%>
                                    <button type="button" onclick="save()" class="btn blue"><i class="fa fa-check"></i> 保存
                                    </button>
                                </div>
                            </div>
                            <div class="portlet-body">
                                <div class="tabbable">
                                    <div class="tab-content no-space">
                                        <div class="tab-pane active" id="tab_general">
                                            <div class="form-body">
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">机具名称:
                                                        <span class="required">*</span>
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input type="text" id="value1" name="value1"
                                                               class="form-control measure-input" datatype="*1-80"
                                                               value="${data.value1}"/>
                                                    </div>
                                                    <div class="col-md-5">
                                                        &nbsp;可输入<b><span id="title_len">80</span></b> 个字符   &nbsp;
                                                
                                                    </div>
                                                </div>
                                             <%--  <div class="form-group">
                                                    <label class="col-md-2 control-label">公开属性:
                                                        <span class="required">*</span>
                                                    </label>
                                                    <div class="col-md-3">
                                                        <select name="status" class="form-control">
                                                            <option value="7" <c:if test="${7== data.status }">selected="selected" </c:if> >不予公开</option>
                                                            <option value="5" <c:if test="${5== data.status }">selected="selected" </c:if> >主动公开</option>
                                                            <option value="6" <c:if test="${6== data.status }">selected="selected" </c:if> >依申请公开</option>
                                                             <option value="0" <c:if test="${0== data.status }">selected="selected" </c:if> >无效</option>
                                                        </select>
                                                    </div>
                                                </div>   --%> 
                                               
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">记录时间:
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input id="falseCreateTime" name="falseCreateTime" type="text"
                                                               class="form-control tags medium"
                                                               value="${data.falseCreateTime}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
                                                    </div>
                                                </div>
                                                <div class="form-group">
														<label class="col-md-2 control-label">编号: <span
															class="required"></span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value3" name="value3"
																class="form-control measure-input" datatype="*1-80"
																value="${data.value3}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">型号: <span
															class="required"></span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value4" name="value4"
																class="form-control measure-input" datatype="*1-80"
																value="${data.value4}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">生产厂家: <span
															class="required"></span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value5" name="value5"
																class="form-control measure-input" datatype="*1-80"
																value="${data.value5}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">使用次数: <span
															class="required"></span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value6" name="value6"
																class="form-control measure-input" datatype="*1-80"
																value="${data.value6}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">上次检定时间: <span
															class="required"></span>
														</label>

														<div class="col-md-5">
															 <input id="value7" name="value7" type="text"
                                                               class="form-control tags medium"
                                                               value="${data.value7}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">检定周期: <span
															class="required"></span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value8" name="value8"
																class="form-control measure-input" datatype="*1-80"
																value="${data.value8}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">状态: <span
															class="required"></span>
														</label>

														<div class="col-md-5">
<!-- 															<input type="text" id="status" name="status" -->
<!-- 																class="form-control measure-input" datatype="*1-80" -->
<!-- 																value="${data.status}" /> -->
																 <select name="status" class="form-control">
											
																<option value="1"
																	<c:if test="${1== data.status }">selected="selected" </c:if>>正常</option>
																<option value="2"
																	<c:if test="${2== data.status }">selected="selected" </c:if>>维修</option>
																<option value="3"
																	<c:if test="${3== data.status }">selected="selected" </c:if>>报废</option>
															</select>
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">备注: <span
															class="required"></span>
														</label>

														<div class="col-md-5">
															<textarea id="value10" name="value10"
                                                               class="form-control tags medium" style="height: 200px ! important;width: 600px ! important;"
                                                               >${data.value10}</textarea>
                                                    	</div>
														</div>
													</div>
                                             <%--    <div class="form-group">
                                                    <label class="col-md-2 control-label">URL:
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input id="isURL" name="isURL" type="text"
                                                               class="form-control tags medium"
                                                               value="${data.isURL}"/>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">文件模板：
                                                        <span class="required">*</span>
                                                    </label>
                                                    <div class="col-md-3">
                                                        <select id="fileTypes" name="fileTypes" class="form-control">
                                                            <option value="1" <c:if test="${1== data.fileTypes }">selected="selected" </c:if> >河公发</option>
                                                            <option value="2" <c:if test="${2== data.fileTypes }">selected="selected" </c:if> >河公通</option>
                                                            <option value="3" <c:if test="${3== data.fileTypes }">selected="selected" </c:if> >河公网发</option>
                                                            <option value="4" <c:if test="${4== data.fileTypes }">selected="selected" </c:if> >河公奖字</option>
                                                            <option value="8" <c:if test="${8== data.fileTypes }">selected="selected" </c:if> >其他</option>
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">文件编号:
                                                    <span class="required">*</span>
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input id="iYears" name="iYears" type="text"
                                                               class="form-control tags medium"
                                                               value="${data.iYears}"/>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">文件签发人:
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input id="iSigner" name="iSigner" type="text"
                                                               class="form-control tags medium"
                                                               value="${data.iSigner}"/>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">文件核稿人:
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input id="isChecked" name="isChecked" type="text"
                                                               class="form-control tags medium"
                                                               value="${data.isChecked}"/>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">文件承办人:
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input id="isHeld" name="isHeld" type="text"
                                                               class="form-control tags medium"
                                                               value="${data.isHeld}"/>
                                                    </div>
                                                </div>

                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">文件发布时间:
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input id="iSignTime" name="iSignTime" type="text"
                                                               class="form-control tags medium"
                                                               value="${data.iSignTime}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
                                                    </div>
                                                </div>
												<div class="form-group">
                                                    <label class="col-md-2 control-label">投稿人:    
                                                    </label>
                                                     <div class="col-md-3">
                                                  <select id="author" name="author" class="form-control">
                                                  <option value="">当前用户 </option>
                                                    <c:forEach items="${deptList}" var="d">
                                                            <option value="${d.value3 }"<c:if test="${d.value3==data.author }">selected="selected"</c:if>>${d.value0}</option>
                                                        </c:forEach>
                                                        </select></div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">内容:
                                                        <span class="required">*</span>
                                                    </label>

                                                    <div class="col-md-8">
                                                        <input id="context" type="hidden" name="context">
                                                        <script id="editor" type="text/plain"
                                                                style="height:500px;">${data.context}</script>
                                                    </div>
                                                </div> 
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">签收单位:
                                                        <span class="required">*</span>
                                                    </label>
													<script type="text/javascript">
														//全选 全不选
														function selectAll(){  
														    if ($("#SelectAll").attr("checked")) {  
														        $(":checkbox").attr("checked", true);  
														    } else {  
														        $(":checkbox").attr("checked", false);  
														    }  
														}  
														
														
														//获取所有东津的签收单位
														$(function(){
														  var dwsName = '${data.signDepartment}';
														  $.ajax({										
															    url: _path + "/userColumn/listDjQsdw",
															    type: "POST",
															    dataType: "json",
															    async: false,
															    success: function(jsonMap) {
															    	var list = jsonMap.dataList;
															    	$("#dwInfo").html("");
															        if(list.length>0){
															        	if(null == dwsName){  //添加时获取所有单位
															        		for(var i=0;i<list.length;i++){
																				var dw = list[i];
																				var dInfo = "<label><input type='checkbox' name='ck' value="+dw.value3+">"+dw.value0+"</label>&nbsp;&nbsp;";
																				$("#dwInfo").append(dInfo);
																        	}
															        	}else{  //修改时 比对判断单位是否被选中
															        		for(var i=0;i<list.length;i++){
																				var dw = list[i]; 
																				var names = dwsName.split(";"); 
																				var dInfo = "<label><input type='checkbox' name='ck' value="+dw.value3+">"+dw.value0+"</label>&nbsp;&nbsp;";
																				for(var j=0;j<names.length;j++){
																					var localDw = names[j];
																					if(dw.value3 == localDw){
																						dInfo="<label><input type='checkbox' name='ck' checked value="+dw.value3+">"+dw.value0+"</label>&nbsp;&nbsp;";
																					}
																				}
																				$("#dwInfo").append(dInfo);
																        	}
															        	}
															        	
															        }
															    }
															});
														});
														
														
															var cnt = 49;
															var radiostate = 0;
															function radioChangeRed() {
																if (radiostate == 1) {
																	document.getElementById('isRed').checked = false;
																	radiostate = 0;
																} else {
																	document.getElementById('isRed').checked = true;
																	radiostate = 1;
																}
															}
															function radioChangeNews() {
																if (radiostate == 1) {
																	document.getElementById('isNews').checked = false;
																	radiostate = 0;
																} else {
																	document.getElementById('isNews').checked = true;
																	radiostate = 1;
																}
															}
															
															
														</script>
                                                    	
													
                                                <div class="col-md-3" style="width:640px;">
													<div style="float: left;">
														<span style="color:red;font-size: 18px;">【全选】</span> 
														<label>
															<input type="checkbox" id="SelectAll"  onclick="selectAll();">
														</label><br>
														<div style="float:left;"  id="dwInfo"></div>
													</div>
												</div> --%>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            <div class="portlet-title">
                                <div class="actions btn-set">
                                    <input class="btn default" type="button" value="取消" onclick="javascript:history.go(-1);">
                               	<%--   <c:choose>
									       <c:when test="${data.topTime=='0'||data.topTime==null}">
									              <button type="button" onclick="saveDz()" class="btn  btn-success"><i class="fa icon-flag"></i> 顶置 </button>
									       </c:when>
									       <c:otherwise>
									             <button type="button" onclick="saveRmdz()" class="btn btn-info"><i class="fa  icon-repeat"></i> 取消顶置 </button>
									       </c:otherwise>
									</c:choose>  --%>
                                    <button type="button" onclick="save()" class="btn blue"><i class="fa fa-check"></i> 保存
                                    </button>
                                </div>
                            </div>
                        </div>
                        <input type="hidden" id="id" name="id" value="${data.id}">
                        <input type="hidden" name="topTime"  id="topTime"  value="${data.topTime==null?0:data.topTime}"  /> 
                        <input type="hidden" name="readTimes"  id="readTimes"  value="${data.readTimes}"  /> 
      					<c:if test="${data.signStatus!=null}">
                        <input type="hidden" name="signStatus"  id="signStatus"  value="${data.signStatus}"  /> 
                        </c:if>
                        <input type="hidden" id="zisNews"  name="isNews"  value="${data.isNews==null?1:data.isNews}" /> 
                         <input type="hidden" id="signDepartment" name="signDepartment" >
                         <input type="hidden" id="teams" name="teams" value="${ipaddress}" />
                         <input type="hidden" id="username" name="username" value="${user.username}">
							<input type="hidden" id="summary" name="summary" value="${user.username}">
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<jsp:include page="../common/footer.jsp"/>
<script type="text/javascript" src="${path}/assets/plugins/calendar/WdatePicker.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/jquery-inputmask/jquery.inputmask.bundle.min.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/jquery.input-ip-address-control-1.0.min.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/jquery.pwstrength.bootstrap/src/pwstrength.js"></script>
<script type="text/javascript" src="${path}/assets/scripts/biz/ajaxfileupload.js"></script>
<!-- <script type="text/javascript" src="${path}/assets/plugins/ueditor/ueditor.config.js"></script> -->
<!-- <script type="text/javascript" src="${path}/assets/plugins/ueditor/ueditor.all.min.js"></script> -->
<script type="text/javascript" src="${path}/assets/plugins/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/district/linkagesel-min.js"></script>
<script type="text/javascript" src="${path}/operate/js/topDz.js"></script>
<script>
    var operType = '${operType}';
    var editor, form;

//         UE.getEditor('editor');
        form = $("form").Validform({
            tiptype: function (msg, o, cssctl) {
                //msg：提示信息;
                //o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素（或表单对象），type指示提示的状态，值为1、2、3、4， 1：正在检测/提交数据，2：通过验证，3：验证失败，4：提示ignore状态, curform为当前form对象;
                //cssctl:内置的提示信息样式控制函数，该函数需传入两个参数：显示提示信息的对象 和 当前提示的状态（既形参o中的type）;
                if (!o.obj.is("form")) {//验证表单元素时o.obj为该表单元素，全部验证通过提交表单时o.obj为该表单对象;
                    var objtip = o.obj.siblings(".Validform_checktip");
                    cssctl(objtip, o.type);
                    objtip.text(msg);
                } else {
                    var objtip = o.obj.find("#msgdemo");
                    cssctl(objtip, o.type);
                    objtip.text(msg);
                }
            },
            postonce: true,
            showAllError: true,
            callback: function () {
                save();
            }
        });
        

    function save() {
//         var context = UE.getEditor('editor').getContent();
//         if (!/[\w\W]+/.test(context)) {
//             alert("内容不能为空");
//             return;
//         }
//         $("#context").val(context);
        
//       获取签收单位	
// 		var qsdw = "";
// 		var ckValues = document.getElementsByName("ck");   
// 		for(var i=0;i<ckValues.length;i++){
// 			if(ckValues[i].checked==true){
// 				qsdw = qsdw+ckValues[i].value+";";
// 			}
// 		}
		
// 			alert("当前签收单位"+qsdw);
// 		if(qsdw != ""){
// 			$("#signDepartment").val(qsdw);
// 		}
        
// 	    $("#form").submit();
      //form提交 
 	   App.ajax(_path + "/lhkworks/save", $("form").serialize(), function (data) {
             if (data.statusCode == 200) {
             App.bubble(200, "更新成功！");
         	window.setTimeout(function(){
         		   //window.close();//修改成功，弹出新页面，直接关闭
         		history.go(-1);
                 },400); 
             }else if (data.statusCode == 100){
             	App.bubble(100, "添加成功！");
             	window.setTimeout(function(){
             		//window.close();//
             		history.go(-1);//返回上一级
                  },400); 
             } else {
                App.bubble(500, "信息失败！");
                   // alert("信息失败")
             }
         });
    }
    //radio 判断是否选中
//     $(function(){
//     	var isn=$("#zisNews").val()
//     	if(isn=='1'){
//     		$("#isNews").attr("checked","true");
//     	}else if(isn=='0'){
//     		$("#isNews").removeAttr("checked");
//     	}
//     });
</script>
</body>
</html>